Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix logging levels and go micro default log level #4102

Merged
merged 3 commits into from
Jul 11, 2022
Merged

fix logging levels and go micro default log level #4102

merged 3 commits into from
Jul 11, 2022

Conversation

wkloucek
Copy link
Contributor

@wkloucek wkloucek commented Jul 5, 2022

Description

We've fixed the configuration of logging levels. Previously it was not possible
to configure a service with a more or less verbose log level then all other services
when running in the supervised / runtime mode ocis server.

For example OCIS_LOG_LEVEL=error PROXY_LOG_LEVEL=debug ocis server did not configure
error logging for all services except the proxy, which should be on debug logging. This is now fixed
and working properly.

Also we fixed the format of go-micro logs to always default to error level.
Previously this was only ensured in the supervised / runtime mode.

Related Issue

Motivation and Context

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@update-docs
Copy link

update-docs bot commented Jul 5, 2022

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@wkloucek wkloucek requested review from C0rby and rhafer and removed request for lookacat, kulmann and pascalwengerter July 5, 2022 11:49
@ownclouders
Copy link
Contributor

💥 Acceptance test cs3ApiTests-ocis failed. Further test are cancelled...

Comment on lines 12 to 33
// this is ugly, but "logger.DefaultLogger" is a global variable and we need to set it _before_ anybody uses it
setMicroLogger()
}

// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not
// want to expose to the end user the internal framework logs unless explicitly specified.
func setMicroLogger() {
if os.Getenv("MICRO_LOG_LEVEL") == "" {
_ = os.Setenv("MICRO_LOG_LEVEL", "error")
}

lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL"))
if err != nil {
lev = zerolog.ErrorLevel
}
logger.DefaultLogger = mzlog.NewLogger(
logger.WithLevel(logger.Level(lev)),
logger.WithFields(map[string]interface{}{
"system": "go-micro",
}),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not entirely sure if it works, but wouldn't it be easier to just add this to ocis-pkg/log/log.go? That way it should be possible to also get rid of all the blank ocis-pkg/log/gomicro imports. Or am I missing anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changing this. I tested with your changes and it still works

@sonarcloud
Copy link

sonarcloud bot commented Jul 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@wkloucek wkloucek requested a review from rhafer July 8, 2022 06:09
@wkloucek
Copy link
Contributor Author

wkloucek commented Jul 8, 2022

@rhafer I also removed leftovers from the runtime. The setMicroLogger() will be impolitely called with the import of "github.com/owncloud/ocis/v2/ocis-pkg/log"

@wkloucek wkloucek requested a review from kobergj July 8, 2022 06:10
@wkloucek wkloucek merged commit 9f0a311 into owncloud:master Jul 11, 2022
@wkloucek wkloucek deleted the fix-logging-levels branch July 11, 2022 07:31
ownclouders pushed a commit that referenced this pull request Jul 11, 2022
Merge: e3180fc 83bbaba
Author: Willy Kloucek <34452982+wkloucek@users.noreply.github.com>
Date:   Mon Jul 11 09:31:19 2022 +0200

    Merge pull request #4102 from wkloucek/fix-logging-levels

    fix logging levels and go micro default log level
@micbar micbar mentioned this pull request Jul 19, 2022
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting different log levels per services does not work
3 participants